package ca.eloas.judging.model;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Id;
import sun.security.krb5.internal.ktab.KeyTab;

import javax.naming.Context;
import javax.naming.NamingException;

/**
 * @author JP
 */
abstract public class DBObjectImpl<T> implements DBObject {

    @Id
    private Long id;

    public Key<T> getKey() {

        if ( getParentKey() == null ) {
            return (Key<T>) Key.create(this.getClass(), getId());
        } else {

            return (Key<T>) Key.create(getParentKey(), this.getClass(), getId());
        }
    }

    public Long getId() {
        return id;
    }

    protected Key<?> getParentKey() {

        return null;
    }
}
